<template>
	<view class="body">
		<xk-header title="维修记录"></xk-header>
		<view class="list" >
			<view class="list-item header" @click="orderMore = !orderMore">
				<view>维修单号:  {{data.apply_no}}</view>
				<image v-if="!orderMore" src="/static/up.png"></image>
				<image v-else  src="/static/down.png"></image>
			</view>
			<view v-if="orderMore" class="data-item">
				<view class="order-info">
					<view class="info-item">
						<view class="key">设备信息：</view>
						<text style="word-break:break-all;">{{data.device_code}}-{{data.device_name}}</text>
					</view>
					<view class="info-item"><view class="key">故障描述：</view>{{data.repair_content}}</view>
					<view class="info-item"><view class="key">设备地址：</view>{{data.address || '-'}}</view>
					<view v-if="data.apply_image" class="info-item"><view class="key"></view>
						<image-list :pics="data.apply_image"></image-list>
					</view>
				</view>
			</view>
		</view>

		<view v-if="data.status  > '30'" class="list" >
			<view class="list-item header" @click="more = !more">
				<view>维修记录</view>
				<image v-if="!more" src="/static/up.png"></image>
				<image v-else  src="/static/down.png"></image>
			</view>
			<view v-if="more" class="data-item">
				<view class="order-info">
					<view class="info-item"><view class="key">跟进人：</view>{{data.record_user_name}}</view>
					<view class="info-item"><view class="key">维修类型：</view>{{data.repair_type_name2}}</view>
					<view class="info-item"><view class="key">维修时间：</view>{{data.finish_time | formatDate}}</view>
					<view @click="editMate" class="info-item" style="justify-content: space-between;">
						<view class="key">工单材料：</view>
						<view style="display: flex; align-items: center;">
							<text  v-if="data.dets.length > 0" class="right-title1" style="color: #2C72FF;">已添加{{data.dets.length}}种物料</text>
							<text v-else class="right-title1" style="color: #2C72FF;">查看明细</text>
							<image mode="aspectFill" class="jiantou" src="/static/jiantou.png"/>
						</view>
					</view>
					<view class="info-item"><view class="key">工作时长(小时)：</view>{{data.work_time}}</view>
					<view v-if="data.record_remark" class="info-item"><view class="key">维修描述：</view><text>{{data.record_remark}}</text></view>
					<view v-if="data.repair_image" class="info-item"><view class="key"></view>
						<image-list :pics="data.repair_image"></image-list>
					</view>

					<view v-if="data.evaluate_result" class="info-item"><view class="key">评价结果：</view><text>{{data.evaluate_result | pjResult}}</text></view>
					<view v-if="data.evaluate_content" class="info-item"><view class="key">评价：</view><text>{{data.evaluate_content}}</text></view>

					<view v-if="data.check_user_name" class="info-item"><view class="key">抽查人：</view><text>{{data.check_user_name}}</text></view>
					<view v-if="data.check_result" class="info-item"><view class="key">抽查结果：</view><text>{{data.check_result == '10' ? '合格' : '不合格'}}</text></view>
					<view v-if="data.check_remark" class="info-item"><view class="key">抽查意见：</view><text>{{data.check_remark}}</text></view>
				</view>
			</view>
		</view>

		<view class="common-bottom-view">
			<view class="common-btn" @click="back">返回</view>
		</view>
		<view class="common-zw"></view>
	</view>
</template>

<script>
	const PJRESULT = {'10': '非常满意', '20': '满意', '30': '不满意'}
	export default {
		data() {
			return {
				repairId: '',
				data: {
					dets: []
				},
				backMore: false,
				more: true,
				orderMore: true,
			};
		},
		filters:{
			pjResult(val){
				return PJRESULT[val]
			}
		},
		onLoad(options) {
			this.repairId = options.repairId
			this.getServiceRepairData();
		},
		methods:{
			getServiceRepairData(){
				this.$api.baseData_getPdDeviceRepair(this.repairId).then((res)=>{
					this.data = res.task
				})
			},
			editMate(){
				uni.navigateTo({
					url: '/pagesA/facility-fix/facility-fix-material?type=view&mateList=' + JSON.stringify(this.data.dets)
				})
			},
			back(){
				uni.navigateBack()
			}
		}
	}
</script>

<style lang="scss" scoped>
@import '@/common/from.scss';
</style>
